package se.jocke.nb.proxy.ui;

import java.beans.BeanInfo;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import org.openide.util.ImageUtilities;
import se.jocke.nb.proxy.ui.node.HttpMessageNode;

/**
 *
 * @author jocke
 */
public class HttpMessageCell extends javax.swing.JPanel {

    private static final String DEFAULT_ICON = "org/openide/resources/defaultNode.gif";

    /**
     * Creates new form HttpMessageCellRenderer
     */
    public HttpMessageCell(HttpMessageNode messageNode) {
        initComponents();

        uriLabel.setText("<html>" + messageNode.getHtmlDisplayName() + "</html>");

        if (messageNode.getIcon(BeanInfo.ICON_COLOR_16x16) != null) {
            uriLabel.setIcon((Icon) messageNode.getIcon(BeanInfo.ICON_COLOR_16x16));

        } else {
            uriLabel.setIcon(new ImageIcon(ImageUtilities.loadImage(DEFAULT_ICON)));
        }

        statusLabel.setText("<html>" + messageNode.getHtmlDisplayStatus() + "</html>");
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        uriLabel = new javax.swing.JLabel();
        statusLabel = new javax.swing.JLabel();

        setLayout(new java.awt.BorderLayout());
        add(uriLabel, java.awt.BorderLayout.WEST);
        add(statusLabel, java.awt.BorderLayout.EAST);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel statusLabel;
    private javax.swing.JLabel uriLabel;
    // End of variables declaration//GEN-END:variables
}
